import 'package:flutter/material.dart';

///
/// @DIR_PATH：lib/page/common
/// @TIME：2024/6/12 10:43
/// @AUTHOR：starr
/// 通用的组件
///

//通用输入框
Widget commonInput(
    {String? hintText,
    Icon? icon,
    TextEditingController? controller,
    FocusNode? focusNode,
    bool? isObscure,
    ValueChanged<String>? onSubmitted}) {
  return TextField(
    textInputAction: TextInputAction.search,
    keyboardType: TextInputType.text,
    decoration: InputDecoration(
      fillColor: Colors.white,
      filled: true,
      contentPadding: const EdgeInsets.all(5),
      enabledBorder: const OutlineInputBorder(
          borderRadius: BorderRadius.all(Radius.circular(15)),
          borderSide: BorderSide(color: Colors.white)
        ),
        focusedBorder: const OutlineInputBorder(
            borderRadius: BorderRadius.all(Radius.circular(15)),
            borderSide: BorderSide(color: Colors.teal)
        ),
        hintText: hintText ?? "",
        prefixIcon: icon ?? const Icon(Icons.email_outlined)),
    controller: controller,
    focusNode: focusNode,
    obscureText: isObscure ?? false,
    onSubmitted: onSubmitted,
  );
}

//通用密码输入框
Widget passwordInput(
    {String? hintText,
    Icon? icon,
    TextEditingController? controller,
    FocusNode? focusNode,
    required bool isObscure,
    ValueChanged<String>? onSubmitted,
    VoidCallback? onObscurePress}) {
  return TextField(
    decoration: InputDecoration(
        hintText: hintText ?? "",
        prefixIcon: icon ?? const Icon(Icons.email_outlined),
        suffixIcon: IconButton(
          icon:
              Icon(isObscure == true ? Icons.visibility_off : Icons.visibility),
          onPressed: onObscurePress,
        )),
    controller: controller,
    focusNode: focusNode,
    obscureText: isObscure,
    onSubmitted: onSubmitted,
  );
}
